package com.atguigu.eduservice.controller;


import com.atguigu.commonutils.Result;
import com.atguigu.eduservice.entity.vo.OneSubjectVO;
import com.atguigu.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author zr
 * @since 2021-11-11
 */
@Api(tags = "课程分类管理")
//@CrossOrigin //跨域
@RestController
@RequestMapping("/edu/service/subject")
public class EduSubjectController {
    @Resource
    private EduSubjectService eduSubjectService;

    //添加课程分类
    @ApiOperation(value = "Excel批量导入")
    @PostMapping("addSubject")
    public Result addSubject(MultipartFile file) {
        //1 获取上传的excel文件 MultipartFile
        eduSubjectService.saveSubject(file, eduSubjectService);
        return Result.ok();
    }

    @ApiOperation(value = "分类列表")
    @GetMapping("getAllSubject")
    public Result getAllSubject() {
        List<OneSubjectVO> oneSubjectVOS = eduSubjectService.getAllOneTwoSubject();
        return Result.ok(oneSubjectVOS);
    }
}

